home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT48.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.2 KB  |  71 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 48                         
  5.                                                                               
  6.  Demonstrates the use of the wremap command. A block will be loaded and      
  7.  shown in its desired colors. It will then be shown using the default        
  8.  palette, and then remapped and shown again with the default palette.        
  9.  The routine will produce an image which fits the current palette as much    
  10.  as possible.                                                                
  11.                                                                               
  12.  *** PROJECT ***                                                             
  13.  This program requires the WGT5_WC.LIB file to be linked.                    
  14.                                                                               
  15.  *** DATA FILES ***                                                          
  16.  WGT1.PCX must be in the executable directory.                  
  17.                                                            WATCOM C++ VERSION 
  18. ==============================================================================
  19. */
  20.  
  21. #include <stdlib.h>
  22. #include <conio.h>
  23. #include <wgt5.h>
  24.  
  25. block myimage;
  26. color desired[256], defaultpal[256];
  27.  
  28. void main (void)
  29. {
  30.   short oldmode;
  31.  
  32.   if ( !vgadetected () )
  33.   {
  34.     printf ("Error - VGA card required for any WGT program.\n");
  35.     exit (0);
  36.   }
  37.   printf ("WGT Example #48\n\n");
  38.   printf ("The WREMAP command is demonstrated by loading in image from disk and trying\n");
  39.   printf ("to display it with the default palette. The same image is then displayed\n");
  40.   printf ("after being remapped. Press a key to skip each screen.\n");
  41.   printf ("\n\nPress any key to continue.\n");
  42.   getch();
  43.  
  44.   oldmode = wgetmode ();         /* Store current video mode     */
  45.   vga256 ();                     /* Initialize WGT system        */
  46.  
  47.   wtextcolor (15);              /* Text color will be white */
  48.   wtexttransparent (TEXTFGBG);  /* No transparencies */
  49.  
  50.   myimage = wloadpcx ("wgt1.pcx", desired); /* Load the image */
  51.   wreadpalette (0, 255, defaultpal);    /* Store default palette */
  52.  
  53.   wsetpalette (0, 255, desired);        /* Now set the palette */
  54.   wputblock (0, 0, myimage, NORMAL);    /* And show the image */
  55.   wouttextxy (10, 180, NULL, "Using image palette");
  56.   getch ();                             /* Wait for keypress */
  57.  
  58.   wsetpalette (0, 255, defaultpal);     /* Set to default palette */
  59.   wouttextxy (10, 180, NULL, "Using default palette");
  60.   getch ();                             /* Wait for keypress */
  61.  
  62.   wremap (desired, myimage, defaultpal);/* Remap the image */
  63.   wputblock (0, 0, myimage, NORMAL);    /* And show the image */
  64.   wouttextxy (10, 180, NULL, "Using default palette after WREMAP");
  65.   getch ();                             /* Wait for keypress */
  66.  
  67.   wfreeblock (myimage);                 /* Deallocate the image */
  68.  
  69.   wsetmode (oldmode);                   /* Reset to text mode */
  70. }
  71.